﻿using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts
{
    [DataContract(Namespace = WebConstants.ServiceNamespace)]
    public class MaterialCriteria : Material
    {
        //public MaterialCriteria()
        //{
        //    AddValidationFor(() => TotalQuantityFrom)
        //        .When(x =>
        //                  {
        //                      var xx = (MaterialCriteria)x;
        //                      if (xx.TotalQuantityFrom.CompareTo(xx.TotalQuantityTo) > 0 && xx.totalQuantityTo >0 && xx.totalQuantityFrom >0)
        //                      {
        //                          return true;
        //                      }
        //                      else
        //                      {
        //                          return false;
        //                      }
                              
        //                  })
        //        .Show("Tổng số lượng ko hợp lệ");

        //    AddValidationFor(() => TotalQuantityTo)
        //        .When(x =>
        //        {
        //            var xx = (MaterialCriteria)x;
        //            if (xx.TotalQuantityFrom.CompareTo(xx.TotalQuantityTo) > 0 && xx.totalQuantityTo > 0 && xx.totalQuantityFrom > 0)
        //            {
        //                return true;
        //            }
        //            else
        //            {
        //                return false;
        //            }

        //        })
        //        .Show("Tổng số lượng ko hợp lệ");

        //}
        
        private DateTime lastImportedDateFrom;
        [DataMember]
        public DateTime LastImportedDateFrom
        {
            get { return lastImportedDateFrom; }
            set
            {
                if(!Equals(lastImportedDateFrom,value))
                {
                    lastImportedDateFrom = value;
                    RaisePropertyChanged(() => LastImportedDateFrom);
                }
            }
        }

        private DateTime lastImportedDateTo;
        [DataMember]
        public DateTime LastImportedDateTo
        {
            get { return lastImportedDateTo; }
            set
            {
                if (!Equals(lastImportedDateTo, value))
                {
                    lastImportedDateTo = value;
                    RaisePropertyChanged(() => LastImportedDateTo);
                }
            }
        }

        private long? totalQuantityFrom;
        [DataMember]
        public long? TotalQuantityFrom
        {
            get { return totalQuantityFrom; }
            set
            {
                if(!Equals(totalQuantityFrom,value))
                {
                    totalQuantityFrom = value;
                    RaisePropertyChanged(() => TotalQuantityFrom);
                }
            }
        }

        private long? totalQuantityTo;
        [DataMember]
        public long? TotalQuantityTo
        {
            get { return totalQuantityTo; }
            set
            {
                if (!Equals(totalQuantityTo, value))
                {
                    totalQuantityTo = value;
                    RaisePropertyChanged(() => TotalQuantityTo);
                }
            }
        }

        private ObservableCollection<int> warehouseIDCollection;
        [DataMember]
        public ObservableCollection<int> WarehouseIDCollection
        {
            get { return warehouseIDCollection; }
            set
            {
                if(!ReferenceEquals(warehouseIDCollection,value))
                {
                    warehouseIDCollection = value;
                    RaisePropertyChanged(() => WarehouseIDCollection);
                }
            }
        }

        private Warehouse selectedWarehouse;
        [DataMember]
        public Warehouse SelectedWarehouse
        {
            get { return selectedWarehouse; }
            set
            {
                if (!ReferenceEquals(selectedWarehouse, value))
                {
                    selectedWarehouse = value;
                    RaisePropertyChanged(() => SelectedWarehouse);
                }
            }
        }

        private ObservableCollection<int> supplierIDCollection;
        [DataMember]
        public ObservableCollection<int> SupplierIDCollection
        {
            get { return supplierIDCollection; }
            set
            {
                if(!ReferenceEquals(supplierIDCollection,value))
                {
                    supplierIDCollection = value;
                    RaisePropertyChanged(() => SupplierIDCollection);
                }
            }
        }
    }
}